<?php
require './include/global.php';
require './include/validate.php';
require './include/all_left.php';

require_once './include/advisory_db.php';
//print_r($_SESSION);
$smarty->compile_check = true;

$smarty->display('header.tpl');
$jid   = trim($_GET[jid]);
$smarty->assign("view",$_GET[view]);

//edit()
if($_GET[rid]){
	$sql = "SELECT * FROM pa_resume WHERE re_id = '".$_GET[rid]."' ";
	$editresume = $DB->fetch_one_array($sql);
	$jid = $editresume[re_aliasid];
}


$smarty->assign('jid',$jid);

$sql    = "SELECT * FROM pa_job WHERE jo_id = '".$jid."'";
//echo $sql;
$jobarr = $DB->fetch_one_array($sql);
if($jobarr[jo_uid]==$_SESSION[uid]){
   $err = "Invalid ID!";
   $smarty->assign("err",$err);
   $smarty->display("left.tpl");
   $smarty->display("error.tpl");
   $smarty->display("right.tpl");
   $smarty->display('footer.tpl');
   exit;
}
//print_r($jobarr);
if($jobarr[jo_updtime]=='0') $jobarr[jo_updtime] = $jobarr[jo_regtime];
$jobarr[jo_updtime] = date("m/d/Y",$jobarr[jo_updtime]);
$jobarr[jo_regtime] = date("m/d/Y",$jobarr[jo_regtime]);
$jobarr[jo_status]  = $jobfillstatus[$jobarr[jo_status]];

$smarty->assign("jobarr",$jobarr);
$smarty->assign("fee_options",$fee_options);
//preview
if($_POST[preview] == " Preview "){
	$smarty->assign('s',$_POST);
	$smarty->assign("view",1);
	$editresume = $_POST;
}else{
		//echo $_SESSION[uid];
		include ("./check/resumepostresume.php");
		if(empty($_POST) && empty($editresume)){

			$list = $DB->fetch_one_array("SELECT * FROM " . $db_prefix . "resume WHERE re_usertype='".$_SESSION[usertype]."' AND re_uid ='" . $_SESSION[uid]."' ORDER BY re_regtime ASC  ");
			
			$list[re_yearexp] = $yearexp2[$list[re_yearexp]];
			$list[re_mgmt] = $yearexp2[$list[re_mgmt]];
			$list[re_detail] = HTMLSPECIALCHARS($list[re_detail]);
			
			$smarty->assign('s',$list);

		}elseif(!empty($editresume)){
			$smarty->assign('s',$editresume);
			$smarty->assign("editid",$editresume[re_id]);
		}else{
			$_POST[re_detail] = HTMLSPECIALCHARS($_POST[re_detail]);
			$smarty->assign('s',$_POST);
		}
}

if($_GET[country]==''){
$_GET[country] = 211;
}

//jobupdate
$smarty->assign('jobupdate_names',$UPDATE);
$smarty->assign('state',$state);
$smarty->assign('country',$country);
$smarty->assign('education',$education);
$smarty->assign('yearexp2',$yearexp2);

$smarty->assign("stateView",$state[$editresume[re_lostate]]);
$smarty->assign("countryView",$country[$editresume[re_locountry]]);
$smarty->assign("re_yearexpView",$yearexp2[$editresume[re_yearexp]]);
$smarty->assign("re_mgmtView", $yearexp2[$editresume[re_mgmt]]);
$smarty->assign("degreeView",  $education[$editresume[re_edulevel]]);

$smarty->assign('industry',$jobcategory);
$smarty->assign('function',$jobfunction);
$smarty->assign('salary',$salary);
$smarty->assign('jobtype',$jobtype);
$smarty->assign('rec_findapplicant',$all_submitapplicant);
//only resumeid


if ($err != '')
{
	$smarty->assign("err", $err);
}

$smarty->display('allleft.tpl');
$smarty->display('resumesubmitresume.tpl');
$smarty->display('footer.tpl');
?>